package mymap.utils.map;

import java.awt.Image;
import java.io.IOException;
import java.net.URL;

import javax.imageio.ImageIO;

 
public class GoogleMaps { 

    public static String KEY = "ABQIAAAApuYOgO4rUF1GDfygR9Sl3hSew5HWQjMwa15hC_lRkgLLqGYUhhS1lve8YMyxORJwm1sDLpHOXq5UVw";
    
 
    public static String getMapUrl(int width, int height, double lng, double lat, int zoom, String format) { 
        return "http://maps.google.com/staticmap?center=" + lat + "," + lng + "&format=" 
                + format + "&zoom=" + zoom + "&size=" + width + "x" + height + "&key=" + GoogleMaps.KEY; 
    } 
 
    /**
     * Retorna uma imagem estatica de um mapa do GMaps
     * @param width
     * @param height
     * @param lng
     * @param lat
     * @param zoom
     * @param format
     * @return
     * @throws IOException
     */
    public Image getMap(int width, int height, double lng, double lat, int zoom, String format) throws IOException{
    	//System.out.println("Iniciando Requisição: [Lat: "+
    	//		lat + " - Long: " + lng + "]");
    	Image image = null;
        URL url = new URL(getMapUrl(width, height, lng, lat, zoom, format));
        image = ImageIO.read(url);
        return image;
        
    }
    
    
}